﻿///////////////////////////////////////////////////////////////////////////////
// Activity: program.activity0
// ForLoop type definitions
///////////////////////////////////////////////////////////////////////////////

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Xml;

using ccr = Microsoft.Ccr.Core;
using dss = Microsoft.Dss.Core;
using dssa = Microsoft.Dss.Core.Attributes;
using dssh = Microsoft.Dss.Core.DsspHttp;
using dssm = Microsoft.Dss.ServiceModel.DsspServiceBase;
using dssp = Microsoft.Dss.ServiceModel.Dssp;
using soap = W3C.Soap;

using submgr = Microsoft.Dss.Services.SubscriptionManager;

namespace ProMRDS.Customactivityorder.ForLoop
{
    static class Contract
    {
        public const string Identifier = "http://schemas.tempuri.org/2008/10/customactivityorder/forloop.html";
    }

    [dssa.DataContract]
    public class ForLoopState
    {
        int _end;
        [dssa.DataMember]
        public int End
        {
            get { return _end; }
            set { _end = value; }
        }

        int _current;
        [dssa.DataMember]
        public int Current
        {
            get { return _current; }
            set { _current = value; }
        }
    }

    #region Custom message types

    [dssa.DataContract]
    public class InitializeRequest
    {
        int _startValue;
        [dssa.DataMember]
        public int StartValue
        {
            get { return _startValue; }
            set { _startValue = value; }
        }

        int _endValue;
        [dssa.DataMember]
        public int EndValue
        {
            get { return _endValue; }
            set { _endValue = value; }
        }
    }

    [dssa.DataContract]
    public class InitializeResponse
    {
        int _startValue;
        [dssa.DataMember]
        public int StartValue
        {
            get { return _startValue; }
            set { _startValue = value; }
        }

        int _endValue;
        [dssa.DataMember]
        public int EndValue
        {
            get { return _endValue; }
            set { _endValue = value; }
        }
    }

    [dssa.DataContract]
    public class CountRequest
    {
    }

    [dssa.DataContract]
    public class CountResponse
    {
    }

    #endregion

    #region Custom notification types

    [dssa.DataContract]
    public class CountNotificationBody
    {
        int _count;
        [dssa.DataMember]
        public int Count
        {
            get { return _count; }
            set { _count = value; }
        }
    }

    #endregion

    #region Operations Port

    public class ForLoopOperations : ccr.PortSet
    {
        public ForLoopOperations() : base (
            typeof(dssp.DsspDefaultLookup),
            typeof(dssp.DsspDefaultDrop),
            typeof(dssh.HttpGet),
            typeof(Initialize),
            typeof(Count),
            typeof(CountNotification),
            typeof(Get),
            typeof(Replace),
            typeof(Subscribe)
        )
        {
        }

        public static implicit operator ccr.Port<dssp.DsspDefaultLookup>(ForLoopOperations portSet)
        {
            if (portSet == null)
            {
                return null;
            }
            return (ccr.Port<dssp.DsspDefaultLookup>)portSet[typeof(dssp.DsspDefaultLookup)];
        }

        public void Post(dssp.DsspDefaultLookup msg)
        {
            base.PostUnknownType(msg);
        }

        public static implicit operator ccr.Port<dssp.DsspDefaultDrop>(ForLoopOperations portSet)
        {
            if (portSet == null)
            {
                return null;
            }
            return (ccr.Port<dssp.DsspDefaultDrop>)portSet[typeof(dssp.DsspDefaultDrop)];
        }

        public void Post(dssp.DsspDefaultDrop msg)
        {
            base.PostUnknownType(msg);
        }

        public static implicit operator ccr.Port<Get>(ForLoopOperations portSet)
        {
            if (portSet == null)
            {
                return null;
            }
            return (ccr.Port<Get>)portSet[typeof(Get)];
        }

        public void Post(Get msg)
        {
            base.PostUnknownType(msg);
        }

        public static implicit operator ccr.Port<Replace>(ForLoopOperations portSet)
        {
            if (portSet == null)
            {
                return null;
            }
            return (ccr.Port<Replace>)portSet[typeof(Replace)];
        }

        public void Post(Replace msg)
        {
            base.PostUnknownType(msg);
        }

        public static implicit operator ccr.Port<Subscribe>(ForLoopOperations portSet)
        {
            if (portSet == null)
            {
                return null;
            }
            return (ccr.Port<Subscribe>)portSet[typeof(Subscribe)];
        }

        public void Post(Subscribe msg)
        {
            base.PostUnknownType(msg);
        }

        public static implicit operator ccr.Port<Initialize>(ForLoopOperations portSet)
        {
            if (portSet == null)
            {
                return null;
            }
            return (ccr.Port<Initialize>)portSet[typeof(Initialize)];
        }

        public void Post(Initialize msg)
        {
            base.PostUnknownType(msg);
        }

        public static implicit operator ccr.Port<Count>(ForLoopOperations portSet)
        {
            if (portSet == null)
            {
                return null;
            }
            return (ccr.Port<Count>)portSet[typeof(Count)];
        }

        public void Post(Count msg)
        {
            base.PostUnknownType(msg);
        }

        public static implicit operator ccr.Port<CountNotification>(ForLoopOperations portSet)
        {
            if (portSet == null)
            {
                return null;
            }
            return (ccr.Port<CountNotification>)portSet[typeof(CountNotification)];
        }

        public void Post(CountNotification msg)
        {
            base.PostUnknownType(msg);
        }

        public dssp.DsspResponsePort<InitializeResponse> Initialize(InitializeRequest body)
        {
            Initialize message = new Initialize();
            message.Body = body;

            this.Post(message);

            return message.ResponsePort;
        }

        public dssp.DsspResponsePort<CountResponse> Count(CountRequest body)
        {
            Count message = new Count();
            message.Body = body;

            this.Post(message);

            return message.ResponsePort;
        }

        public dssp.DsspResponsePort<dssp.SubscribeResponseType> Subscribe(ccr.IPort notificationPort)
        {
            Subscribe message = new Subscribe();
            message.NotificationPort = notificationPort;

            this.Post(message);

            return message.ResponsePort;
        }
    }

    #endregion

    #region Standard DSSP message definitions

    [Description("Retrieves the current state of the service")]
    public class Get : dssp.Get<dssp.GetRequestType, dssp.DsspResponsePort<ForLoopState>>
    {
    }

    [Description("Sets the current state of the service.\nThis is raised as an event whenever the state changes.")]
    public class Replace : dssp.Replace<ForLoopState, dssp.DsspResponsePort<dssp.DefaultReplaceResponseType>>
    {
    }

    public class Subscribe : dssp.Subscribe<dssp.SubscribeRequestType, dssp.DsspResponsePort<dssp.SubscribeResponseType>>
    {
    }

    #endregion

    #region Custom message definitions

    public class Initialize : dssp.Update<InitializeRequest, dssp.DsspResponsePort<InitializeResponse>>
    {
    }

    public class Count : dssp.Update<CountRequest, dssp.DsspResponsePort<CountResponse>>
    {
    }

    public class CountNotification : dssp.Update<CountNotificationBody, dssp.DsspResponsePort<dssp.DefaultUpdateResponseType>>
    {
    }

    #endregion
}
